package com.wc.alorithm_blue_bridge._DFS.Q5315;

import java.util.*;

/**
 * @Author congege
 * @Description
 * 张三的社团小游戏1
 * https://www.lanqiao.cn/problems/5315/learning/?page=1&first_category_id=1
 * @Date Created in 2023/11/28-11:46
 */
public class Main {
    static int[] array;
    // 为了全排列
    static boolean[] vis;
    static int n;
    static char[] operators = new char[]{'*', '+', '-'};
    static ArrayList<String> ansStr = new ArrayList<>();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        array = new int[n];
        vis = new boolean[n];

        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        // 需要排序
        Arrays.sort(array);
        // 递归遍历
        for (int i = 0; i < n; i++) {
            vis[i] = true;
            StringBuffer operate = new StringBuffer();
            operate.append(array[i]);
            if (dfs(operate, 1)) {
                break;
            }
            vis[i] = false;
        }

        if (ansStr.size() == 0) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
            String ans = ansStr.get(0);
            int size = ansStr.size();
            for (int i = 1; i < size; i++) {
                if (ans.compareTo(ansStr.get(i)) > 0) {
                    ans = ansStr.get(i);
                }
            }
            System.out.println(ans);
        }
    }

    public static boolean dfs(StringBuffer operate, int floor) {
        // 到达最后一层的计算
        if (floor == array.length) {
            if (isTwentyFour(operate.toString())) {
                ansStr.add(operate.append("=24").toString());
                return true;
            }
            return false;
        }
        for (int i = 0; i < n; i++) {
            if (!vis[i]) {
                vis[i] = true;
                // 遍历运算符
                for (char operator : operators) {
                    if (cal(new StringBuffer(operate), operator, i, floor)) {
                        return true;
                    }
                }
                vis[i] = false;
            }
        }
        return false;
    }

    // 插入
    static public boolean cal(StringBuffer operate, char operator, int numIdx, int floor) {
        operate.append(operator);
        operate.append(array[numIdx]);
        return dfs(operate, floor + 1);
    }


    /**
     * 计算是否为24
     * @param s
     * @return
     */
    public static boolean isTwentyFour(String s) {
        char[] chs = s.toCharArray();
        double preNum = 0;
        Stack<Double> nums = new Stack<>();
        Stack<Character> operators = new Stack<>();
        for (int i = 0; i < chs.length; i++) {
            if (chs[i] >= '0' && chs[i] <= '9') {
                preNum = preNum * 10 + chs[i] - '0';
            } else {
                if (preNum != 0) {
                    nums.push(preNum);
                }
                preNum = 0;
                operators.push(chs[i]);
                if (chs[i] == '*' || chs[i] == '/') {
                    i++;
                    while (i < chs.length && chs[i] >= '0' && chs[i] <= '9') {
                        preNum = preNum * 10 + chs[i] - '0';
                        i++;
                    }
                    // 恢复一下,抵消上面的i++
                    i--;
                    nums.push(calculate(nums.pop(), preNum, operators.pop()));
                }
                preNum = 0;
            }
        }
        if (preNum != 0) {
            nums.push(preNum);
        }
        LinkedList<Double> numsReverse = new LinkedList<>();
        LinkedList<Character> operatorsReverse = new LinkedList<>();

        while (!nums.isEmpty()){
            numsReverse.addFirst(nums.pop());
        }
        while (!operators.isEmpty()){
            operatorsReverse.addFirst(operators.pop());
        }
        int size = operatorsReverse.size();
        for (int i = 0; i < size; i++) {
            char operator = operatorsReverse.get(i);
            double a = numsReverse.get(i);
            double b = numsReverse.get(i + 1);
            numsReverse.set(i + 1,calculate(a,b,operator));
        }

        return numsReverse.get(size) == 24;
    }

    // 计算+ - * / 结果除法没有
    public static double calculate(double a, double b, char operator) {
        switch (operator) {
            case '+':
                return a + b;
            case '-':
                return a - b;
            case '*':
                return a * b;
            case '/':
                // 要影响他们
                if (a % b != 0) {
                    return Double.MIN_VALUE;
                }
                return a / b;
        }
        return 0;
    }
}
